package community.hospital.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import community.hospital.annotation.Log;
import community.hospital.annotation.Module;
import community.hospital.annotation.NeedLogin;
import community.hospital.annotation.NeedPermission;
import community.hospital.common.R;
import community.hospital.entity.OperationLog;
import community.hospital.entity.request.OperationLogRequest;
import community.hospital.service.domain.OperationLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static community.hospital.common.Constant.LOG_QUERY;
import static community.hospital.common.PermissionConstant.LIST_OPERATION_LOG;
import static community.hospital.common.PermissionConstant.SUPER_ADMIN;

/**
 * @Author：ydj
 * @Date：2023/2/4 18:44
 */
@RestController
@RequestMapping("/logs")
@Module("日志")
public class OperationLogController {
    @Resource
    private OperationLogService operationLogService;
    @PostMapping ("/listLogs")
    @NeedLogin
    @NeedPermission(role = SUPER_ADMIN,permission = LIST_OPERATION_LOG)
    @Log(methodName = LOG_QUERY,desc = "分页查询日志信息")
    public R<Page<OperationLog>> listOperationLog(@RequestBody @Valid OperationLogRequest request) {
        Page<OperationLog> respPage = operationLogService.listOperationLog(request);
        return R.ok(respPage);
    }
}
